How to use builders - 8 common examples

To help you get started, we’ve selected a few builders examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rtymchyk / babel-plugin-extract-text / test / builders.spec.js View on Github external
it('builds plural entry with context from call expression', () => {
      const path = {
        node: {
          callee: { name: '_nc' },
          arguments: [
            { value: 'One' },
            { value: 'Many' },
            { value: 10 },
            { value: 'Some context' },
          ],
        },
      }

      expect(buildCallExpressionEntry(types, path, state)).toEqual({
        msgid: 'One',
        msgid_plural: 'Many',
        msgctxt: 'Some context',
      })
    })
github rtymchyk / babel-plugin-extract-text / test / builders.spec.js View on Github external
it('plural entry contains 2 msgstr', () => {
      const result = mergeEntries({}, [{
        msgid_plural: 'Many',
        msgid: 'One',
      }])

      expect(result.translations[''].One.msgstr).toEqual(['', ''])
    })
github rtymchyk / babel-plugin-extract-text / test / builders.spec.js View on Github external
it('includes default charset and headers if included', () => {
      const charset = 'UTF-8'
      const expectedHeaders = {
        'content-type': 'text/plain; charset=UTF-8',
        'plural-forms': 'nplurals=2; plural=(n!=1);',
        language: 'en_US',
      }
      const result = mergeEntries({}, [])

      expect(result.charset).toEqual(charset)
      expect(result.headers).toEqual(expectedHeaders)
    })
github rtymchyk / babel-plugin-extract-text / test / builders.spec.js View on Github external
it('strips up to base directory from reference if found', () => {
      const result = buildReference(
        { msgid: 'Hello' },
        Object.assign({}, state, {
          opts: {
            includeReference: true,
            baseDir: 'project',
          },
        }))

      expect(result.reference).toBe('js/code.js')
    })
github rtymchyk / babel-plugin-extract-text / test / builders.spec.js View on Github external
expect(() => {
        const entry = buildCallExpressionEntry(types, path, Object.assign({}, state, {
          opts: {
            function: [
              {
                type: 'SINGULAR',
                name: '_',
                singular: 0,
                ignoreError: true,
              },
            ],
          },
        }))
        expect(entry).toBeUndefined()
      }).not.toThrow()
    })
github rtymchyk / babel-plugin-extract-text / test / builders.spec.js View on Github external
      expect(() => buildCallExpressionEntry(types, path, state)).toThrow(/string literal/i)
    })
github rtymchyk / babel-plugin-extract-text / test / builders.spec.js View on Github external
value: { value: 'Context' },
            }, {
              name: { name: 'comment' },
              value: { value: 'On homepage' },
            }, {
              name: { name: 'numFriends' },
              value: { value: '10,000' },
            }, {
              name: { name: 'count' },
              value: { value: 10000 },
            }],
          },
        },
      }

      expect(buildJSXElementEntry(types, path, state)).toEqual({
        msgid: 'You have one friend!',
        msgid_plural: 'You have {numFriends} friends!',
        msgctxt: 'Context',
        extracted: 'On homepage',
      })
    })
github buildbot / buildbot / www / console_view / src / module / main.module.spec.js View on Github external
xit('should match sort the builders by tag groups', function() {
        createController();
        const _builders = FIXTURES['builders.fixture.json'].builders;
        for (let builder of Array.from(_builders)) {
            builder.hasBuild = true;
        }
        scope.c.sortBuildersByTags(_builders);
        expect(_builders.length).toBe(scope.c.builders.length);
        expect(scope.c.tag_lines.length).toEqual(5);
    });
});