How to use unregister method in avocado

Best Python code snippet using avocado_python

core.registry.tests.js

Source:core.registry.tests.js Github

copy

Full Screen

...11 Chart.register(CustomController);12 expect(Chart.registry.getController('custom')).toEqual(CustomController);13 expect(Chart.defaults.datasets.custom).toEqual(CustomController.defaults);14 expect(Chart.overrides.custom).toEqual(CustomController.overrides);15 Chart.unregister(CustomController);16 expect(function() {17 Chart.registry.getController('custom');18 }).toThrow(new Error('"custom" is not a registered controller.'));19 expect(Chart.overrides.custom).not.toBeDefined();20 expect(Chart.defaults.datasets.custom).not.toBeDefined();21 });22 it('should handle an ES6 scale extension', function() {23 class CustomScale extends Chart.Scale {}24 CustomScale.id = 'es6Scale';25 CustomScale.defaults = {26 foo: 'bar'27 };28 Chart.register(CustomScale);29 expect(Chart.registry.getScale('es6Scale')).toEqual(CustomScale);30 expect(Chart.defaults.scales.es6Scale).toEqual(CustomScale.defaults);31 Chart.unregister(CustomScale);32 expect(function() {33 Chart.registry.getScale('es6Scale');34 }).toThrow(new Error('"es6Scale" is not a registered scale.'));35 expect(Chart.defaults.scales.es6Scale).not.toBeDefined();36 });37 it('should handle an ES6 element extension', function() {38 class CustomElement extends Chart.Element {}39 CustomElement.id = 'es6element';40 CustomElement.defaults = {41 foo: 'bar'42 };43 Chart.register(CustomElement);44 expect(Chart.registry.getElement('es6element')).toEqual(CustomElement);45 expect(Chart.defaults.elements.es6element).toEqual(CustomElement.defaults);46 Chart.unregister(CustomElement);47 expect(function() {48 Chart.registry.getElement('es6element');49 }).toThrow(new Error('"es6element" is not a registered element.'));50 expect(Chart.defaults.elements.es6element).not.toBeDefined();51 });52 it('should handle an ES6 plugin', function() {53 class CustomPlugin {}54 CustomPlugin.id = 'es6plugin';55 CustomPlugin.defaults = {56 foo: 'bar'57 };58 Chart.register(CustomPlugin);59 expect(Chart.registry.getPlugin('es6plugin')).toEqual(CustomPlugin);60 expect(Chart.defaults.plugins.es6plugin).toEqual(CustomPlugin.defaults);61 Chart.unregister(CustomPlugin);62 expect(function() {63 Chart.registry.getPlugin('es6plugin');64 }).toThrow(new Error('"es6plugin" is not a registered plugin.'));65 expect(Chart.defaults.plugins.es6plugin).not.toBeDefined();66 });67 it('should not accept an object without id', function() {68 expect(function() {69 Chart.register({foo: 'bar'});70 }).toThrow(new Error('class does not have id: bar'));71 class FaultyPlugin {}72 expect(function() {73 Chart.register(FaultyPlugin);74 }).toThrow(new Error('class does not have id: class FaultyPlugin {}'));75 });76 it('should not fail when unregistering an object that is not registered', function() {77 expect(function() {78 Chart.unregister({id: 'foo'});79 }).not.toThrow();80 });81 describe('Should allow registering explicitly', function() {82 class customExtension {}83 customExtension.id = 'custom';84 customExtension.defaults = {85 prop: true86 };87 it('as controller', function() {88 Chart.registry.addControllers(customExtension);89 expect(Chart.registry.getController('custom')).toEqual(customExtension);90 expect(Chart.defaults.datasets.custom).toEqual(customExtension.defaults);91 Chart.registry.removeControllers(customExtension);92 expect(function() {93 Chart.registry.getController('custom');94 }).toThrow(new Error('"custom" is not a registered controller.'));95 expect(Chart.defaults.datasets.custom).not.toBeDefined();96 });97 it('as scale', function() {98 Chart.registry.addScales(customExtension);99 expect(Chart.registry.getScale('custom')).toEqual(customExtension);100 expect(Chart.defaults.scales.custom).toEqual(customExtension.defaults);101 Chart.registry.removeScales(customExtension);102 expect(function() {103 Chart.registry.getScale('custom');104 }).toThrow(new Error('"custom" is not a registered scale.'));105 expect(Chart.defaults.scales.custom).not.toBeDefined();106 });107 it('as element', function() {108 Chart.registry.addElements(customExtension);109 expect(Chart.registry.getElement('custom')).toEqual(customExtension);110 expect(Chart.defaults.elements.custom).toEqual(customExtension.defaults);111 Chart.registry.removeElements(customExtension);112 expect(function() {113 Chart.registry.getElement('custom');114 }).toThrow(new Error('"custom" is not a registered element.'));115 expect(Chart.defaults.elements.custom).not.toBeDefined();116 });117 it('as plugin', function() {118 Chart.registry.addPlugins(customExtension);119 expect(Chart.registry.getPlugin('custom')).toEqual(customExtension);120 expect(Chart.defaults.plugins.custom).toEqual(customExtension.defaults);121 Chart.registry.removePlugins(customExtension);122 expect(function() {123 Chart.registry.getPlugin('custom');124 }).toThrow(new Error('"custom" is not a registered plugin.'));125 expect(Chart.defaults.plugins.custom).not.toBeDefined();126 });127 });128 it('should fire before/after callbacks', function() {129 let beforeRegisterCount = 0;130 let afterRegisterCount = 0;131 let beforeUnregisterCount = 0;132 let afterUnregisterCount = 0;133 class custom {}134 custom.id = 'custom';135 custom.beforeRegister = () => beforeRegisterCount++;136 custom.afterRegister = () => afterRegisterCount++;137 custom.beforeUnregister = () => beforeUnregisterCount++;138 custom.afterUnregister = () => afterUnregisterCount++;139 Chart.registry.addControllers(custom);140 expect(beforeRegisterCount).withContext('beforeRegister').toBe(1);141 expect(afterRegisterCount).withContext('afterRegister').toBe(1);142 Chart.registry.removeControllers(custom);143 expect(beforeUnregisterCount).withContext('beforeUnregister').toBe(1);144 expect(afterUnregisterCount).withContext('afterUnregister').toBe(1);145 Chart.registry.addScales(custom);146 expect(beforeRegisterCount).withContext('beforeRegister').toBe(2);147 expect(afterRegisterCount).withContext('afterRegister').toBe(2);148 Chart.registry.removeScales(custom);149 expect(beforeUnregisterCount).withContext('beforeUnregister').toBe(2);150 expect(afterUnregisterCount).withContext('afterUnregister').toBe(2);151 Chart.registry.addElements(custom);152 expect(beforeRegisterCount).withContext('beforeRegister').toBe(3);153 expect(afterRegisterCount).withContext('afterRegister').toBe(3);154 Chart.registry.removeElements(custom);155 expect(beforeUnregisterCount).withContext('beforeUnregister').toBe(3);156 expect(afterUnregisterCount).withContext('afterUnregister').toBe(3);157 Chart.register(custom);158 expect(beforeRegisterCount).withContext('beforeRegister').toBe(4);159 expect(afterRegisterCount).withContext('afterRegister').toBe(4);160 Chart.unregister(custom);161 expect(beforeUnregisterCount).withContext('beforeUnregister').toBe(4);162 expect(afterUnregisterCount).withContext('afterUnregister').toBe(4);163 });164 it('should preserve existing defaults', function() {165 Chart.defaults.datasets.test = {test1: true, test3: false};166 Chart.overrides.test = {testA: true, testC: false};167 class testController extends Chart.DatasetController {}168 testController.id = 'test';169 testController.defaults = {test1: false, test2: true};170 testController.overrides = {testA: false, testB: true};171 Chart.register(testController);172 expect(Chart.defaults.datasets.test).toEqual({test1: false, test2: true, test3: false});173 expect(Chart.overrides.test).toEqual({testA: false, testB: true, testC: false});174 Chart.unregister(testController);175 expect(Chart.defaults.datasets.test).not.toBeDefined();176 expect(Chart.overrides.test).not.toBeDefined();177 });178 describe('should handle multiple items', function() {179 class test1 extends Chart.DatasetController {}180 test1.id = 'test1';181 class test2 extends Chart.Scale {}182 test2.id = 'test2';183 it('separately', function() {184 Chart.register(test1, test2);185 expect(Chart.registry.getController('test1')).toEqual(test1);186 expect(Chart.registry.getScale('test2')).toEqual(test2);187 Chart.unregister(test1, test2);188 expect(function() {189 Chart.registry.getController('test1');190 }).toThrow();191 expect(function() {192 Chart.registry.getScale('test2');193 }).toThrow();194 });195 it('as array', function() {196 Chart.register([test1, test2]);197 expect(Chart.registry.getController('test1')).toEqual(test1);198 expect(Chart.registry.getScale('test2')).toEqual(test2);199 Chart.unregister([test1, test2]);200 expect(function() {201 Chart.registry.getController('test1');202 }).toThrow();203 expect(function() {204 Chart.registry.getScale('test2');205 }).toThrow();206 });207 it('as object', function() {208 Chart.register({test1, test2});209 expect(Chart.registry.getController('test1')).toEqual(test1);210 expect(Chart.registry.getScale('test2')).toEqual(test2);211 Chart.unregister({test1, test2});212 expect(function() {213 Chart.registry.getController('test1');214 }).toThrow();215 expect(function() {216 Chart.registry.getScale('test2');217 }).toThrow();218 });219 });...

Full Screen

Full Screen

WrongCases.js

Source:WrongCases.js Github

copy

Full Screen

...4 describe('Logs a warn message when called', () => {5 const warn = message => `WARN! Impossible to unregister action with message "${message}".\nIt is not a registered action for this worker.`6 test('with more than one action, being only one registered', () => {7 const spy = console.warn = jest.fn()8 const unregisterMock = unregister([9 { message: 'a', func: () => 'a' },10 { message: 'b', func: () => 'a' }11 ])12 unregisterMock(['a', 'c'])13 expect(spy).toHaveBeenCalledWith(warn('c'))14 expect(spy).toHaveBeenCalledTimes(1)15 return spy.mockRestore()16 })17 test('with one action message that is not registered', () => {18 const spy = console.warn = jest.fn()19 const unregisterMock = unregister([{ message: 'a', func: () => 'a' }])20 unregisterMock('b')21 expect(spy).toHaveBeenCalledWith(warn('b'))22 expect(spy).toHaveBeenCalledTimes(1)23 return spy.mockRestore()24 })25 test('with more than one action, being none registered', () => {26 const spy = console.warn = jest.fn()27 const unregisterMock = unregister([28 { message: 'a', func: () => 'a' },29 { message: 'b', func: () => 'a' }30 ])31 unregisterMock(['d', 'c'])32 expect(spy).toHaveBeenCalledWith(warn('d'))33 expect(spy).toHaveBeenCalledWith(warn('c'))34 expect(spy).toHaveBeenCalledTimes(2)35 return spy.mockRestore()36 })37 })38 describe('Returns the length of [actions] when called', () => {39 test('with more than one action, being only one registered', () => {40 const actions = [41 { message: 'a', func: () => 'a' },42 { message: 'b', func: () => 'a' }43 ]44 const unregisterMock = unregister(actions)45 const expected = 146 const actual = unregisterMock(['a', 'c'])47 expect(actions.length).toBe(expected)48 expect(actual).toBe(expected)49 })50 test('with one action message that is not registered', () => {51 const actions = [{ message: 'a', func: () => 'a' }]52 const unregisterMock = unregister(actions)53 const expected = 154 const actual = unregisterMock('b')55 expect(actions.length).toBe(expected)56 expect(actual).toBe(expected)57 })58 test('with more than one action, being none registered', () => {59 const actions = [60 { message: 'a', func: () => 'a' },61 { message: 'b', func: () => 'a' }62 ]63 const unregisterMock = unregister(actions)64 const expected = 265 const actual = unregisterMock(['d', 'c'])66 expect(actions.length).toBe(expected)67 expect(actual).toBe(expected)68 })69 })70 describe('Logs an error when message is', () => {71 const error = received => new TypeError(`You should provide an array of strings or a string\n\nReceived: ${received}`)72 test('an object', () => {73 const spy = console.error = jest.fn()74 unregister([{ message: 'a', func: () => 'a' }])({an: 'object'})75 expect(spy).toHaveBeenCalledWith(error('{"an":"object"}'))76 expect(spy).toHaveBeenCalledTimes(1)77 return spy.mockRestore()78 })79 test('a number', () => {80 const spy = console.error = jest.fn()81 unregister([{ message: 'a', func: () => 'a' }])(1)82 expect(spy).toHaveBeenCalledWith(error('1'))83 expect(spy).toHaveBeenCalledTimes(1)84 return spy.mockRestore()85 })86 test('undefined', () => {87 const spy = console.error = jest.fn()88 unregister([{ message: 'a', func: () => 'a' }])()89 expect(spy).toHaveBeenCalledWith(error('null'))90 expect(spy).toHaveBeenCalledTimes(1)91 return spy.mockRestore()92 })93 test('null', () => {94 const spy = console.error = jest.fn()95 unregister([{ message: 'a', func: () => 'a' }])(null)96 expect(spy).toHaveBeenCalledWith(error('null'))97 expect(spy).toHaveBeenCalledTimes(1)98 return spy.mockRestore()99 })100 test('an array with something beside strings', () => {101 const spy = console.error = jest.fn()102 unregister([{ message: 'a', func: () => 'a' }])(['an', 'array', {with: 'object'}])103 expect(spy).toHaveBeenCalledWith(error('["an","array",{"with":"object"}]'))104 expect(spy).toHaveBeenCalledTimes(1)105 return spy.mockRestore()106 })107 })108 describe('Returns null when message is', () => {109 test('an object', () => expect(unregister([])({an: 'object'})).toBeNull())110 test('a number', () => expect(unregister([])(1)).toBeNull())111 test('undefined', () => expect(unregister([])()).toBeNull())112 test('null', () => expect(unregister([])(null)).toBeNull())113 test('an array with something beside strings', () => expect(unregister([])(['an', 'array', {with: 'object'}])).toBeNull())114 })115 })...

Full Screen

Full Screen

Resource.spec.js

Source:Resource.spec.js Github

copy

Full Screen

1import React from 'react';2import assert from 'assert';3import { shallow } from 'enzyme';4import { Resource } from './Resource';5import { Route } from 'react-router-dom';6const PostList = () => <div>PostList</div>;7const PostEdit = () => <div>PostEdit</div>;8const PostCreate = () => <div>PostCreate</div>;9const PostShow = () => <div>PostShow</div>;10const PostIcon = () => <div>PostIcon</div>;11const resource = {12 name: 'posts',13 options: { foo: 'bar' },14 list: PostList,15 edit: PostEdit,16 create: PostCreate,17 show: PostShow,18 icon: PostIcon,19};20describe('<Resource>', () => {21 const registerResource = jest.fn();22 const unregisterResource = jest.fn();23 it(`registers its resource in redux on mount when context is 'registration'`, () => {24 shallow(25 <Resource26 {...resource}27 context="registration"28 registerResource={registerResource}29 unregisterResource={unregisterResource}30 />31 );32 assert.equal(registerResource.mock.calls.length, 1);33 assert.deepEqual(registerResource.mock.calls[0][0], {34 name: 'posts',35 options: { foo: 'bar' },36 hasList: true,37 hasEdit: true,38 hasShow: true,39 hasCreate: true,40 icon: PostIcon,41 });42 });43 it(`unregister its resource from redux on unmount when context is 'registration'`, () => {44 const wrapper = shallow(45 <Resource46 {...resource}47 context="registration"48 registerResource={registerResource}49 unregisterResource={unregisterResource}50 />51 );52 wrapper.unmount();53 assert.equal(unregisterResource.mock.calls.length, 1);54 assert.deepEqual(unregisterResource.mock.calls[0][0], 'posts');55 });56 it('renders list route if specified', () => {57 const wrapper = shallow(58 <Resource59 {...resource}60 context="route"61 match={{ url: 'posts' }}62 registerResource={registerResource}63 unregisterResource={unregisterResource}64 />65 );66 assert.ok(wrapper.containsMatchingElement(<Route path="posts" />));67 });68 it('renders create route if specified', () => {69 const wrapper = shallow(70 <Resource71 {...resource}72 context="route"73 match={{ url: 'posts' }}74 registerResource={registerResource}75 unregisterResource={unregisterResource}76 />77 );78 assert.ok(79 wrapper.containsMatchingElement(<Route path="posts/create" />)80 );81 });82 it('renders edit route if specified', () => {83 const wrapper = shallow(84 <Resource85 {...resource}86 context="route"87 match={{ url: 'posts' }}88 registerResource={registerResource}89 unregisterResource={unregisterResource}90 />91 );92 assert.ok(wrapper.containsMatchingElement(<Route path="posts/:id" />));93 });94 it('renders show route if specified', () => {95 const wrapper = shallow(96 <Resource97 {...resource}98 context="route"99 match={{ url: 'posts' }}100 registerResource={registerResource}101 unregisterResource={unregisterResource}102 />103 );104 assert.ok(105 wrapper.containsMatchingElement(<Route path="posts/:id/show" />)106 );107 });...

Full Screen

Full Screen

blacklist.js

Source:blacklist.js Github

copy

Full Screen

1/**2 * Block Blacklist3 */4wp.domReady(function() {5 wp.blocks.unregisterBlockType('core/verse');6 wp.blocks.unregisterBlockType('core/audio');7 wp.blocks.unregisterBlockType('core/group');8 // wp.blocks.unregisterBlockType('core/button');9 wp.blocks.unregisterBlockType('core/quote');10 wp.blocks.unregisterBlockType('core/file');11 wp.blocks.unregisterBlockType('core/cover');12 // wp.blocks.unregisterBlockType('core/freeform');13 wp.blocks.unregisterBlockType('core/html');14 wp.blocks.unregisterBlockType('core/code');15 wp.blocks.unregisterBlockType('core/preformatted');16 wp.blocks.unregisterBlockType('core/pullquote');17 wp.blocks.unregisterBlockType('core/table');18 wp.blocks.unregisterBlockType('core/media-text');19 wp.blocks.unregisterBlockType('core/more');20 wp.blocks.unregisterBlockType('core/nextpage');21 wp.blocks.unregisterBlockType('core/separator');22 wp.blocks.unregisterBlockType('core/calendar');23 wp.blocks.unregisterBlockType('core/archives');24 wp.blocks.unregisterBlockType('core/categories');25 wp.blocks.unregisterBlockType('core/latest-comments');26 wp.blocks.unregisterBlockType('core/latest-posts');27 wp.blocks.unregisterBlockType('core/rss');28 wp.blocks.unregisterBlockType('core/search');29 wp.blocks.unregisterBlockType('core/tag-cloud');30 wp.blocks.unregisterBlockType('core/embed');31 wp.blocks.unregisterBlockType('core-embed/twitter');32 wp.blocks.unregisterBlockType('core-embed/facebook');33 wp.blocks.unregisterBlockType('core-embed/instagram');34 wp.blocks.unregisterBlockType('core-embed/wordpress');35 wp.blocks.unregisterBlockType('core-embed/soundcloud');36 wp.blocks.unregisterBlockType('core-embed/spotify');37 wp.blocks.unregisterBlockType('core-embed/flickr');38 wp.blocks.unregisterBlockType('core-embed/vimeo');39 wp.blocks.unregisterBlockType('core-embed/animoto');40 wp.blocks.unregisterBlockType('core-embed/cloudup');41 wp.blocks.unregisterBlockType('core-embed/collegehumor');42 wp.blocks.unregisterBlockType('core-embed/dailymotion');43 wp.blocks.unregisterBlockType('core-embed/hulu');44 wp.blocks.unregisterBlockType('core-embed/imgur');45 wp.blocks.unregisterBlockType('core-embed/issuu');46 wp.blocks.unregisterBlockType('core-embed/kickstarter');47 wp.blocks.unregisterBlockType('core-embed/meetup-com');48 wp.blocks.unregisterBlockType('core-embed/mixcloud');49 wp.blocks.unregisterBlockType('core-embed/polldaddy');50 wp.blocks.unregisterBlockType('core-embed/reddit');51 wp.blocks.unregisterBlockType('core-embed/reverbnation');52 wp.blocks.unregisterBlockType('core-embed/screencast');53 wp.blocks.unregisterBlockType('core-embed/scribd');54 wp.blocks.unregisterBlockType('core-embed/smugmug');55 wp.blocks.unregisterBlockType('core-embed/speaker');56 wp.blocks.unregisterBlockType('core-embed/ted');57 wp.blocks.unregisterBlockType('core-embed/tumblr');58 wp.blocks.unregisterBlockType('core-embed/videopress');59 wp.blocks.unregisterBlockType('core-embed/wordpress-tv');60 wp.blocks.unregisterBlockType('core-embed/crowdsignal');61 wp.blocks.unregisterBlockType('core-embed/slideshare');62 wp.blocks.unregisterBlockType('core-embed/speaker-deck');63 wp.blocks.unregisterBlockType('core-embed/amazon-kindle');...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful