Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alice/feature endorse #37

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions test/posts/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use strict';

const assert = require('assert');
const db = require('../mocks/databasemock');
const plugins = require('../../src/plugins');
const user = require('../../src/user');
const topics = require('../../src/topics');
const categories = require('../../src/categories');
const groups = require('../../src/groups');
const privileges = require('../../src/privileges');
const meta = require('../../src/meta');

Check failure on line 11 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected 1 empty line after require statement not followed by another require
const Posts = {};

describe('create post', () => {
let pid;

Check failure on line 15 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
let purgePid;

Check failure on line 16 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
let cid;

Check failure on line 17 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
let uid;

Check failure on line 18 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
let endorsed;

Check failure on line 19 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces

before(async () => {

Check failure on line 21 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
// Create a user

Check failure on line 22 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces
uid = await user.create({

Check failure on line 23 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces
username: 'uploads user',

Check failure on line 24 in test/posts/create.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 3 tabs but found 12 spaces
password: 'abracadabra',
gdpr_consent: 1,
});

// Create a test category
({ cid } = await categories.create({
name: 'Test Category',
description: 'Test category created by testing script',
}));
});

it('create a post where endorsed is automatically false', async () => {
try {
// Create a post within the category
const topicPostData = await topics.post({
uid,
cid,
title: 'topic with some images',
content: 'here is an image [alt text](/assets/uploads/files/abracadabra.png) and another [alt text](/assets/uploads/files/shazam.jpg)',
});

// Check if 'endorsed' is false
endorsed = topicPostData.postData.endorsed;
assert.strictEqual(endorsed, false);
} catch (error) {
console.log(error);
}
});

it('create a post where endorsed is initialized to be true', async () => {
try {
// Create a post within the category
const topicPostData = await topics.post({
uid,
cid,
title: 'topic with some images',
content: 'here is an image [alt text](/assets/uploads/files/abracadabra.png) and another [alt text](/assets/uploads/files/shazam.jpg)',
endorsed: true,
});

// Check if 'endorsed' is true
endorsed = topicPostData.postData.endorsed;
assert.strictEqual(endorsed, true);
} catch (error) {
console.log(error);
}
});
});