mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
test: Add tests for push (#614)
* Add support for the Jekyll sample filter See https://jekyllrb.com/docs/liquid/filters I am sorting the array randomly and then picking the first N items or all items if there is no sample limit. * Add tests for `push` I thought `push` was broken because it doesn't work on the Playground but that's not the case. Here are the tests to prove it. Taken from the `concat` tests. * Remove the sample experiment This got in from another branch lol. * Recommend the build:dist command over the whole build This one works for me locally whereas build:docs is reporting some issues. * Return the full `build` command and explain how to use `commitlint` to workshop the message I am working on a PR to make `build` run on macOS because it is a part of the pre-commit hook anyway so all contributors should make it work for them. I have also shown how to check your messages against `commitlint` from the CLI because it is faster than using the VS Code GUI.
This commit is contained in:
@@ -92,6 +92,27 @@ describe('filters/array', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('push', () => {
|
||||
it('should push arg value', async () => {
|
||||
const scope = { val: ['hey'], arg: 'foo' }
|
||||
await test('{{ val | push: arg | join: "," }}', scope, 'hey,foo')
|
||||
})
|
||||
it('should support undefined left value', async () => {
|
||||
const scope = { arg: 'foo' }
|
||||
await test('{{ notDefined | push: arg | join: "," }}', scope, 'foo')
|
||||
})
|
||||
it('should ignore nil left value', async () => {
|
||||
const scope = { undefinedValue: undefined, nullValue: null, arg: 'foo' }
|
||||
await test('{{ undefinedValue | push: arg | join: "," }}', scope, 'foo')
|
||||
await test('{{ nullValue | push: arg | join: "," }}', scope, 'foo')
|
||||
})
|
||||
it('should ignore nil right value', async () => {
|
||||
const scope = { nullValue: null }
|
||||
await test('{{ nullValue | push | join: "," }}', scope, '')
|
||||
await test('{{ nullValue | push: nil | join: "," }}', scope, '')
|
||||
})
|
||||
})
|
||||
|
||||
describe('reverse', function () {
|
||||
it('should support reverse', () => test(
|
||||
'{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}',
|
||||
|
||||
Reference in New Issue
Block a user