mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
chore(TypeScript): fix linting and generate .d.ts
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import Liquid from '../../../src/liquid'
|
||||
import { expect } from 'chai'
|
||||
import Liquid from 'src/liquid'
|
||||
import * as mock from 'mock-fs'
|
||||
import * as chai from 'chai'
|
||||
import * as path from 'path'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
let engine = new Liquid()
|
||||
const strictEngine = new Liquid({
|
||||
strict_variables: true,
|
||||
@@ -111,8 +108,9 @@ describe('error', function () {
|
||||
expect(err.name).to.equal('RenderError')
|
||||
expect(err.message).to.contain('throwed by filter')
|
||||
})
|
||||
it('should not throw when variable undefined by default', function () {
|
||||
return expect(engine.parseAndRender('X{{a}}Y')).to.eventually.equal('XY')
|
||||
it('should not throw when variable undefined by default', async function () {
|
||||
const html = await engine.parseAndRender('X{{a}}Y')
|
||||
return expect(html).to.equal('XY')
|
||||
})
|
||||
it('should throw RenderError when variable not defined', async function () {
|
||||
const err = await expect(strictEngine.parseAndRender('{{a}}')).be.rejected
|
||||
|
||||
+18
-13
@@ -1,8 +1,9 @@
|
||||
const chai = require('chai')
|
||||
const sinon = require('sinon')
|
||||
import * as chai from 'chai'
|
||||
import * as sinon from 'sinon'
|
||||
import * as sinonChai from 'sinon-chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
chai.use(require('sinon-chai'))
|
||||
chai.use(sinonChai)
|
||||
|
||||
const P = require('../../../src/util/promise')
|
||||
|
||||
@@ -32,10 +33,12 @@ describe('util/promise', function () {
|
||||
item => Promise.reject(new Error(item)))
|
||||
return expect(p).to.be.rejectedWith('third')
|
||||
})
|
||||
it('should resolve the value that first callback resolved', () => {
|
||||
const p = P.anySeries(['first', 'second'],
|
||||
item => Promise.resolve(item))
|
||||
return expect(p).to.eventually.equal('first')
|
||||
it('should resolve the value that first callback resolved', async () => {
|
||||
const result = await P.anySeries(
|
||||
['first', 'second'],
|
||||
item => Promise.resolve(item)
|
||||
)
|
||||
return expect(result).to.equal('first')
|
||||
})
|
||||
it('should not call rest of callbacks once resolved', () => {
|
||||
const spy = sinon.spy()
|
||||
@@ -50,10 +53,12 @@ describe('util/promise', function () {
|
||||
})
|
||||
})
|
||||
describe('.mapSeries()', function () {
|
||||
it('should resolve when all resolved', function () {
|
||||
const p = P.mapSeries(['first', 'second', 'third'],
|
||||
item => Promise.resolve(item))
|
||||
return expect(p).to.eventually.deep.equal(['first', 'second', 'third'])
|
||||
it('should resolve when all resolved', async function () {
|
||||
const result = P.mapSeries(
|
||||
['first', 'second', 'third'],
|
||||
item => Promise.resolve(item)
|
||||
)
|
||||
return expect(result).to.deep.equal(['first', 'second', 'third'])
|
||||
})
|
||||
it('should reject with the error that first callback rejected', () => {
|
||||
const p = P.mapSeries(['first', 'second'],
|
||||
@@ -66,7 +71,7 @@ describe('util/promise', function () {
|
||||
return P
|
||||
.mapSeries(
|
||||
['first', 'second'],
|
||||
(item, idx) => new Promise(function (resolve, reject) {
|
||||
(item, idx) => new Promise(function (resolve) {
|
||||
if (idx === 0) {
|
||||
setTimeout(function () {
|
||||
spy1()
|
||||
|
||||
Reference in New Issue
Block a user