Skip to content

Commit

Permalink
examples: improve (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustinMauroy authored Jan 19, 2025
1 parent ed3d5e8 commit 803f6ee
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
File renamed without changes.
19 changes: 19 additions & 0 deletions examples/csv-report/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { Suite } = require('../../lib');
const assert = require('node:assert');

const suite = new Suite();

suite
.add('single with matcher', function () {
const pattern = /[123]/g
const replacements = { 1: 'a', 2: 'b', 3: 'c' }
const subject = '123123123123123123123123123123123123123123123123'
const r = subject.replace(pattern, m => replacements[m])
assert.ok(r);
})
.add('multiple replaces', function () {
const subject = '123123123123123123123123123123123123123123123123'
const r = subject.replace(/1/g, 'a').replace(/2/g, 'b').replace(/3/g, 'c')
assert.ok(r);
})
.run();
21 changes: 21 additions & 0 deletions examples/default-report/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { Suite, csvReport } = require('../../lib');
const assert = require('node:assert');

const suite = new Suite({
reporter: csvReport,
});

suite
.add('single with matcher', function () {
const pattern = /[123]/g
const replacements = { 1: 'a', 2: 'b', 3: 'c' }
const subject = '123123123123123123123123123123123123123123123123'
const r = subject.replace(pattern, m => replacements[m])
assert.ok(r);
})
.add('multiple replaces', function () {
const subject = '123123123123123123123123123123123123123123123123'
const r = subject.replace(/1/g, 'a').replace(/2/g, 'b').replace(/3/g, 'c')
assert.ok(r);
})
.run();

0 comments on commit 803f6ee

Please sign in to comment.