Sha256: 01ceba7a1d60ba4163156b8ca44eb56134562054ec295109b3939af0986869d7

Contents?: true

Size: 1.96 KB

Versions: 20

Compression:

Stored size: 1.96 KB

Contents

const { utimesSync } = require('fs');
const { join } = require('path');
const tmp = require('tmp');
const fs = require('fs-extra');
const Depends = require('../../src/depends');
const Fingerprinter = require('../../src/fingerprint/fingerprinter');
const { listAppMapFiles, verbose } = require('../../src/utils');

tmp.setGracefulCleanup();

const fixtureDir = join(__dirname, 'fixtures', 'ruby');
const appMapDir = tmp.dirSync().name;

const userModelFilePath = join(appMapDir, 'app/models/user.rb');
const now = Date.now();

describe('Depends', () => {
  beforeAll(async () => {
    if (process.env.DEBUG) {
      verbose(true);
    }

    fs.copySync(fixtureDir, appMapDir);

    const fingerprinter = new Fingerprinter(true);
    await listAppMapFiles(appMapDir, async (fileName) => {
      utimesSync(fileName, now, now);
      await fingerprinter.fingerprint(fileName);
    });
  });

  test('indicates when no dependency is modified', async () => {
    const fn = new Depends(appMapDir);
    fn.baseDir = join(appMapDir, 'app');
    const depends = await fn.depends();
    expect(depends).toEqual([]);
  });

  test('indicates when a dependency is modified', async () => {
    const future = now + 1000;
    utimesSync(userModelFilePath, future, future);

    const fn = new Depends(appMapDir);
    fn.baseDir = appMapDir;
    const depends = await fn.depends();
    expect(depends).toEqual([join(appMapDir, 'user_page_scenario')]);
  });

  test('indicates dependencies in an explicit list', async () => {
    const fn = new Depends(appMapDir);
    fn.files = ['app/models/user.rb'];
    const depends = await fn.depends();
    expect(depends).toEqual([join(appMapDir, 'user_page_scenario')]);
  });

  test('AppMaps will be yielded to a callback function', async () => {
    const result = [];
    const fn = new Depends(appMapDir);
    fn.files = ['app/models/user.rb'];
    await fn.depends((file) => result.push(file));
    expect(result).toEqual([join(appMapDir, 'user_page_scenario')]);
  });
});

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
appmap-0.72.2 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.72.1 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.72.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.71.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.70.2 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.70.1 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.70.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.69.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.68.2 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.68.1 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.68.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.67.1 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.67.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.66.2 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.66.1 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.66.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.65.1 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.65.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.64.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js
appmap-0.63.0 ./node_modules/@appland/appmap/tests/unit/depends.spec.js