|
| 1 | +/* |
| 2 | + * Copyright (c) 2019-2024 Bjoern Kimminich & the OWASP Juice Shop contributors. |
| 3 | + * SPDX-License-Identifier: MIT |
| 4 | + */ |
| 5 | + |
| 6 | +const chai = require('chai') |
| 7 | +const expect = chai.expect |
| 8 | +const mastodonPost = require('../lib/mastodonPost') |
| 9 | + |
| 10 | +describe('Mastodon post', () => { |
| 11 | + it('should always include robot emoji', () => { |
| 12 | + for (let i = 0; i < 100; i++) { |
| 13 | + expect(mastodonPost()).to.include('[🤖]') |
| 14 | + } |
| 15 | + }) |
| 16 | + |
| 17 | + it('should always include #coupon hashtag', () => { |
| 18 | + for (let i = 0; i < 100; i++) { |
| 19 | + expect(mastodonPost()).to.include('#coupon') |
| 20 | + } |
| 21 | + }) |
| 22 | + |
| 23 | + it('should always mention discount amount', () => { |
| 24 | + for (let i = 10; i < 40; i++) { |
| 25 | + expect(mastodonPost(i)).to.include(i + '%') |
| 26 | + } |
| 27 | + }) |
| 28 | + |
| 29 | + it('should always contain coupon code', () => { |
| 30 | + for (let i = 0; i < 100; i++) { |
| 31 | + expect(mastodonPost(undefined, ':COUPON:')).to.include(':COUPON:') |
| 32 | + } |
| 33 | + }) |
| 34 | + |
| 35 | + it('should always mention expiration date', () => { |
| 36 | + for (let i = 0; i < 100; i++) { |
| 37 | + expect(mastodonPost(undefined, undefined, ':EXPIRATION:')).to.include(':EXPIRATION:') |
| 38 | + } |
| 39 | + }) |
| 40 | + |
| 41 | + it('should never be longer than 500 characters', () => { |
| 42 | + for (let i = 0; i < 100; i++) { |
| 43 | + expect(mastodonPost().length <= 500).to.equal(true) |
| 44 | + } |
| 45 | + }) |
| 46 | +}) |
0 commit comments