INNER CODE UNIT · JavaScript

countPluginKey

serverless/plugins · plugins.test.js:6

const countPluginKey = (plugins, key) => plugins
  .reduce((previous, plugin) => !!plugin[key] ? previous += 1 : previous, 0);

describe('plugins', () => {
  it('should be valid JSON', () => {
    expect(() => {JSON.parse(plugins)}).not.toThrow();
  });

  it('should have all required keys', () => {
    const parsed = JSON.parse(plugins);
    const pluginsCount = parsed.length;

    const nameCount = countPluginKey(parsed, 'name');
    const descriptionCount = countPluginKey(parsed, 'description');
    const githubUrlCount = countPluginKey(parsed, 'githubUrl');

    expect(nameCount).toBe(pluginsCount);
    expect(descriptionCount).toBe(pluginsCount);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…