| 1 | 'use strict'; |
| 2 | |
| 3 | const { action, assert, utils } = require( 'api-testing' ); |
| 4 | |
| 5 | describe( "Changing a user's `editfont` option", () => { |
| 6 | let Rick = action.getAnon(); |
| 7 | const randomPage = utils.title( 'random' ); |
| 8 | const text = 'Random text'; |
| 9 | |
| 10 | before( async () => { |
| 11 | Rick = await Rick.account( 'Rick_' ); |
| 12 | } ); |
| 13 | |
| 14 | it( 'should make edits to a page and update the editcount', async () => { |
| 15 | const result = await Rick.meta( 'userinfo', { uiprop: 'editcount' } ); |
| 16 | const editcount = result.editcount; |
| 17 | |
| 18 | await Rick.edit( randomPage, text ); |
| 19 | await Rick.edit( randomPage, text ); |
| 20 | await Rick.edit( randomPage, text ); |
| 21 | |
| 22 | const updatedResult = await Rick.meta( 'userinfo', { uiprop: 'editcount' } ); |
| 23 | const updatedCount = updatedResult.editcount; |
| 24 | |
| 25 | assert.equal( updatedCount, editcount + 3 ); |
| 26 | } ); |
| 27 | |
| 28 | it( 'should get users default editfont preference', async () => { |
| 29 | const result = await Rick.meta( 'userinfo', { uiprop: 'options' } ); |
| 30 | assert.equal( result.options.editfont, 'monospace' ); |
| 31 | } ); |
| 32 | |
| 33 | it( 'should change editfont preference from monospace to serif', async () => { |
| 34 | const token = await Rick.token(); |
| 35 | const result = await Rick.action( 'options', { change: 'editfont=serif', token }, 'POST' ); |
| 36 | |
| 37 | assert.equal( result.options, 'success' ); |
| 38 | } ); |
| 39 | |
| 40 | it( 'should get users updated editfont preference', async () => { |
| 41 | const result = await Rick.meta( 'userinfo', { uiprop: 'options' } ); |
| 42 | assert.equal( result.options.editfont, 'serif' ); |
| 43 | } ); |
| 44 | } ); |