diff --git a/README.md b/README.md index 18031196..a487a666 100644 --- a/README.md +++ b/README.md @@ -536,25 +536,25 @@ yarn test ```bash // node test run - yarn test scriptlets --name set-cookie - yarn test redirects --name ati-smarttag + yarn test:qunit scriptlets --name set-cookie + yarn test:qunit redirects --name ati-smarttag // gui test run - yarn test scriptlets --name set-cookie --gui - yarn test redirects --name ati-smarttag --gui + yarn test:qunit scriptlets --name set-cookie --gui + yarn test:qunit redirects --name ati-smarttag --gui ``` 1. Run all jest tests: ```bash - yarn jest + yarn test:jest ``` or limit the testing — `testRegex` may be specified in `jest.config.js` or specify [test name](https://jestjs.io/docs/cli#--testnamepatternregex) in command line, e.g.: ```bash - yarn jest -t isValidScriptletRule + yarn test:jest -t isValidScriptletRule ``` To run browserstack tests create `.env` file or copy and rename `.env-example`. diff --git a/tests/scriptlets/trusted-set-cookie.test.js b/tests/scriptlets/trusted-set-cookie.test.js index 2941be7f..b03eade5 100644 --- a/tests/scriptlets/trusted-set-cookie.test.js +++ b/tests/scriptlets/trusted-set-cookie.test.js @@ -26,16 +26,16 @@ test('Set cookie string', (assert) => { let cValue = 'OK'; runScriptlet(name, [cName, cValue]); assert.strictEqual(window.hit, 'FIRED', 'Hit was fired'); - assert.strictEqual(document.cookie.includes(cName), true, 'Cookie name has been set'); - assert.strictEqual(document.cookie.includes(cValue), true, 'Cookie value has been set'); + assert.strictEqual(document.cookie.includes(cName), true, "Cookie with name '__test-cookie_OK' has been set"); + assert.strictEqual(document.cookie.includes(cValue), true, 'Cookie value has been set to OK'); clearCookie(cName); cName = '__test-cookie_0'; cValue = 0; runScriptlet(name, [cName, cValue]); assert.strictEqual(window.hit, 'FIRED', 'Hit was fired'); - assert.strictEqual(document.cookie.includes(cName), true, 'Cookie name has been set'); - assert.strictEqual(document.cookie.includes(cValue), true, 'Cookie value has been set'); + assert.strictEqual(document.cookie.includes(cName), true, "Cookie with name '__test-cookie_0' has been set"); + assert.strictEqual(document.cookie.includes(cValue), true, 'Cookie value has been set to 0'); clearCookie(cName); cName = 'trackingSettings'; @@ -43,8 +43,17 @@ test('Set cookie string', (assert) => { runScriptlet(name, [cName, cValue]); assert.strictEqual(window.hit, 'FIRED', 'Hit was fired'); - assert.strictEqual(document.cookie.includes(cName), true, 'Cookie name has been set'); - assert.strictEqual(document.cookie.includes(cValue), true, 'Cookie value has been set'); + assert.strictEqual(document.cookie.includes(cName), true, "Cookie with name 'trackingSettings' has been set"); + assert.strictEqual(document.cookie.includes(cValue), true, 'Cookie value set to encoded object-like string'); + clearCookie(cName); + + cName = 'CookieConsentV2'; + cValue = 'YES%2CTOI%2CANA%2CKOH'; + runScriptlet(name, [cName, cValue]); + + assert.strictEqual(window.hit, 'FIRED', 'Hit was fired'); + assert.strictEqual(document.cookie.includes(cName), true, "Cookie with name 'CookieConsentV2' has been set"); + assert.strictEqual(document.cookie.includes(cValue), true, 'Cookie value has been set to encoded string'); clearCookie(cName); });