|
| 1 | +/** |
| 2 | + * @athenna/common |
| 3 | + * |
| 4 | + * (c) Robson Trasel <robson@athenna.io> |
| 5 | + * |
| 6 | + * For the full copyright and license information, please view the LICENSE |
| 7 | + * file that was distributed with this source code. |
| 8 | + */ |
| 9 | + |
| 10 | +import { Test, type Context } from '@athenna/test' |
| 11 | + |
| 12 | +export default class GlobalStringTest { |
| 13 | + @Test() |
| 14 | + public async shouldReturnTrueIfAtLeastOneTermMatchesUsingMultipleParams({ assert }: Context) { |
| 15 | + const value = 'Hello model.id and some other text' |
| 16 | + |
| 17 | + assert.isTrue(value.athenna.includesSome('model.id', 'nope')) |
| 18 | + assert.isTrue(value.athenna.includesSome('some', 'anything')) |
| 19 | + assert.isFalse(value.athenna.includesSome('not-found', 'nope')) |
| 20 | + } |
| 21 | + |
| 22 | + @Test() |
| 23 | + public async shouldReturnTrueIfAtLeastOneTermMatchesUsingAnArray({ assert }: Context) { |
| 24 | + const value = 'Hello model.id and some other text' |
| 25 | + |
| 26 | + assert.isTrue(value.athenna.includesSome(['model.id', 'random'])) |
| 27 | + assert.isFalse(value.athenna.includesSome(['aaa', 'bbb'])) |
| 28 | + } |
| 29 | + |
| 30 | + @Test() |
| 31 | + public async shouldReturnFalseForIncludesSomeWithEmptyTerms({ assert }: Context) { |
| 32 | + const value = 'anything' |
| 33 | + |
| 34 | + assert.isFalse(value.athenna.includesSome()) |
| 35 | + assert.isFalse(value.athenna.includesSome([])) |
| 36 | + } |
| 37 | + |
| 38 | + @Test() |
| 39 | + public async shouldReturnTrueOnlyIfAllTermsMatchUsingMultipleParams({ assert }: Context) { |
| 40 | + const value = 'Hello model.id and some text' |
| 41 | + |
| 42 | + assert.isFalse(value.athenna.includesEvery('Hello', 'somethingElse')) |
| 43 | + assert.isTrue(value.athenna.includesEvery('Hello', 'model.id')) |
| 44 | + assert.isFalse(value.athenna.includesEvery('model.id', 'not-found')) |
| 45 | + } |
| 46 | + |
| 47 | + @Test() |
| 48 | + public async shouldReturnTrueOnlyIfAllTermsMatchUsingAnArray({ assert }: Context) { |
| 49 | + const value = 'Hello model.id and some text' |
| 50 | + |
| 51 | + assert.isTrue(value.athenna.includesEvery(['Hello', 'model.id'])) |
| 52 | + assert.isFalse(value.athenna.includesEvery(['Hello', 'random'])) |
| 53 | + } |
| 54 | + |
| 55 | + @Test() |
| 56 | + public async shouldReturnTrueForIncludesEveryWithEmptyTerms({ assert }: Context) { |
| 57 | + const value = 'anything' |
| 58 | + |
| 59 | + assert.isTrue(value.athenna.includesEvery()) |
| 60 | + assert.isTrue(value.athenna.includesEvery([])) |
| 61 | + } |
| 62 | +} |
0 commit comments