Skip to content

Commit

Permalink
spec/conditions/operation: add tests for 'matches'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidor committed Jan 3, 2019
1 parent 96e5b9c commit afb78f5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spec/conditions/operation_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ describe('Operation', function()
assert.is_false(Operation.new('1', 'plain', '!=', '1', 'plain'):evaluate({}))
end)

it('evaluates "matches"', function()
assert.is_true(
Operation.new('something_abc_something', 'plain', 'matches', '.*_abc_.*', 'plain')
:evaluate({})
)

assert.is_false(
Operation.new('something_abc_something', 'plain', 'matches', 'abc_$', 'plain')
:evaluate({})
)

assert.is_true(
Operation.new('12345', 'plain', 'matches', '^123', 'plain')
:evaluate({})
)

assert.is_false(
Operation.new('abc', 'plain', 'matches', '^123', 'plain')
:evaluate({})
)
end)

it('evaluates values as plain text by default', function()
assert.is_true(Operation.new('1', nil, '==', '1', nil):evaluate({}))
assert.is_false(Operation.new('1', nil, '==', '2', nil):evaluate({}))
Expand Down

0 comments on commit afb78f5

Please sign in to comment.