Skip to content

Commit cda29e8

Browse files
committed
Remove deprecated uuid import.
1 parent ce3c733 commit cda29e8

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/handlers/CreateActivityHandler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ActivityHandler from './ActivityHandler';
22
import activityTemplate from './activity.ttl';
33
import { replaceVariables } from '../util';
44
import { namedNode, literal } from '@rdfjs/data-model';
5-
import uuid from 'uuid/v4';
5+
import { v4 as uuidv4 } from 'uuid';
66
import context from '@solid/context';
77

88
const { xsd } = context['@context'];
@@ -17,7 +17,7 @@ const { xsd } = context['@context'];
1717
export default class CreateActivityHandler extends ActivityHandler {
1818
// Creates an activity for insertion in the given document
1919
async* createResults(activity, document) {
20-
const id = namedNode(new URL(`#${uuid()}`, document).href);
20+
const id = namedNode(new URL(`#${uuidv4()}`, document).href);
2121
const published = literal(new Date().toISOString(), `${xsd}dateTime`);
2222
activity = { id, published, ...activity };
2323

test/__mocks__/uuid.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let counter = 1;
2+
export function v4() {
3+
return `${counter++}`;
4+
}
5+
v4.reset = function () {
6+
counter = 1;
7+
};

test/__mocks__/uuid/v4.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/unit/handlers/CreateActivityHandler-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import CreateActivityHandler from '../../../src/handlers/CreateActivityHandler';
2-
import uuid from 'uuid/v4';
2+
import { v4 as uuidv4 } from 'uuid';
33

44
Date.prototype.toISOString = () => '2019-01-01T20:00:00.000Z';
55

@@ -29,7 +29,7 @@ describe('a CreateActivityHandler instance', () => {
2929
};
3030

3131
// perform the activity
32-
uuid.reset();
32+
uuidv4.reset();
3333
const createActivity = handler.handle({ settings: { queryEngine } }, path);
3434
const iterator = createActivity();
3535
results = [];
@@ -86,7 +86,7 @@ INSERT {
8686
};
8787

8888
// perform the activity
89-
uuid.reset();
89+
uuidv4.reset();
9090
const createActivity = handler.handle({ settings: { queryEngine } }, path);
9191
const iterator = createActivity('https://www.w3.org/ns/activitystreams#Follow');
9292
results = [];

0 commit comments

Comments
 (0)